package com.atguigu.spzx.manager.controller;

import com.atguigu.spzx.manager.service.SysMenuService;
import com.atguigu.spzx.model.entity.system.SysMenu;
import com.atguigu.spzx.model.vo.common.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/admin/system/sysMenu")
@CrossOrigin(allowCredentials = "true" , originPatterns = "*" , allowedHeaders = "*")
public class SysMenuController {

    @Autowired
    private SysMenuService sysMenuService;

    @GetMapping("/findNodes")
    public Result<List<SysMenu>> findNodes(){
        List<SysMenu> sysMenuList = sysMenuService.findNodes();
        return Result.ok(sysMenuList);
    }
    @PostMapping("/saveSysMenu")
    public Result saveSysMenu(@RequestBody SysMenu sysMenu){
        sysMenuService.saveSysMenu(sysMenu);
        return Result.ok(null);
    }
    @PutMapping("/updateSysMenu")
    public Result updateSysMenu(@RequestBody SysMenu sysMenu){
        sysMenuService.updateSysMenu(sysMenu);
        return Result.ok(null);

    }
    @DeleteMapping("/removeSysMenuById/{menuId}")
    public Result removeSysMenuById(@PathVariable Long menuId){
        sysMenuService.removeSysMenuById(menuId);
        return Result.ok(null);
    }

}
